package cinema.service;

import cinema.model.Manager;
import cinema.model.customer;
import cinema.model.systemAdmin;
import cinema.model.tickerSeller;

import java.util.HashMap;
import java.util.Map;

public class Login {
    private Map<String, Manager>users1=new HashMap<>();
    private Map<String, tickerSeller>users2=new HashMap<>();
    private Map<String, customer>users3=new HashMap<>();
    private Map<String, systemAdmin>users4=new HashMap<>();
    public Login(){
        users1.put("manager", new Manager("customer", "a123456"));
        users2.put("tickerSeller", new tickerSeller("tickerSeller", "b123456"));
        users3.put("customer", new customer("customer", "c123456"));
        users4.put("systemAdmin",new systemAdmin("systemAdmin","d123456"));
    }
    // 登录方法，根据角色类型进行校验
    public boolean login(String role, String userName, String passWord) {
        switch (role) {
            case "manager":
                Manager manager = users1.get(userName);
                return manager != null && manager.getPassWord().equals(passWord);
            case "tickerSeller":
                tickerSeller tickerSeller = users2.get(userName);
                return tickerSeller != null && tickerSeller.getPassWord().equals(passWord);
            case "customer":
                customer customer = users3.get(userName);
                return customer != null && customer.getPassWord().equals(passWord);
            case "systemAdmin":
                systemAdmin systemAdmin=users4.get(userName);
                return systemAdmin!=null&&systemAdmin.getPassWord().equals(passWord);
            default:
                System.out.println("无效的角色类型");
                return false;
        }
    }
}
